library STRLIB;

uses
  SysUtils,
  Classes;

type
  TAcceptProc =function(source,subStr,
                                              pos:PChar):Boolean; stdcall;

function SearchStr(source,subStr:PChar;
                                      AcceptFunct:Pointer):integer; 
																		stdcall; export;
var p:PChar;
       f:TAcceptProc;

begin
   p:=source; result:=0;

   if AcceptFunct=nil then begin
      if StrPos(subStr,p)<>nil then inc(result);
      exit;
   end;

   f:=AcceptFunct;

   while (p<>nil) do begin
     p:=StrPos(p,subStr);
     if p<>nil then begin  
        if f(source,subStr,p) then begin
                     inc(result);
                     p:=p+1;   
       end else 
                     p:=nil;

    end;
  end;

end;

exports
   SearchStr index 1;

begin

end.
